package com.android.place360.appsettings;

import com.android.place360.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
import android.util.Log;

public class SharePreference_Setting {
	
	public static String getLanguage(Context context){
		SharedPreferences shareRefs = PreferenceManager.getDefaultSharedPreferences(context);
		return shareRefs.getString("language",context.getString(R.string.default_language ));
	}
	
	public static int getNumberOfResults(Context context){
		SharedPreferences shareRefs = PreferenceManager.getDefaultSharedPreferences(context);
		int num = 10;
		try{
		 num =Integer.parseInt(shareRefs.getString("number_of_results", "10"));
		}catch (Exception e) {
			Log.i("error", "SharePreference_Setting Class: "+e.getMessage()); 
		}
		return num;
	}
//	public static void setNumberOfResults(Context context, int value){
//		SharedPreferences shareRefs = PreferenceManager.getDefaultSharedPreferences(context);
//		Editor editor  = shareRefs.edit();
//		editor.putInt("number_of_results", value);
//		editor.commit();
//	}
	
	public static boolean isTheFirstRun(Context context){
		SharedPreferences shareRefs = PreferenceManager.getDefaultSharedPreferences(context);
		return shareRefs.getBoolean("is_first_run", true);
	}
	public static void setTheFirstRun(Context context, boolean value){
		SharedPreferences shareRefs = PreferenceManager.getDefaultSharedPreferences(context);
		Editor editor  = shareRefs.edit();
		editor.putBoolean("is_first_run", value);
		editor.commit();
	}
	
	
}
